package com.ruoyi.web.controller.prevention;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.entity.PreventionRiskStudyandjudge;
import com.ruoyi.system.service.*;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;


@RestController
@RequestMapping("preventionRiskStudyandjudge")
public class PreventionRiskStudyandjudgeController extends BaseController {

    @Resource
    private PreventionRiskStudyandjudgeService preventionRiskStudyandjudgeService;


    /**
     * 分页查询
     * @param preventionRiskStudyandjudge 筛选条件
     * @return 查询结果
     */
    @GetMapping("/list")
    public TableDataInfo queryByPage(PreventionRiskStudyandjudge preventionRiskStudyandjudge) {
        startPage();
        List<PreventionRiskStudyandjudge> preventionRiskStudyandjudgeList = this.preventionRiskStudyandjudgeService.queryByPage(preventionRiskStudyandjudge);
        return getDataTable(preventionRiskStudyandjudgeList);
    }


    /**
     * 导出
     * @param response
     * @param ids
     */
    @Log(title = "风险研判(", businessType = BusinessType.EXPORT)
    @PostMapping("/exportData")
    public void export(HttpServletResponse response, @RequestBody Integer[] ids) {
        List<PreventionRiskStudyandjudge> promiseList = new ArrayList<>();
        List<Integer> list = new ArrayList<>(Arrays.asList(ids));
        if (!CollectionUtils.isEmpty(list)) {
            for (Integer id : list) {
                PreventionRiskStudyandjudge promise = preventionRiskStudyandjudgeService.queryById(id);
                promiseList.add(promise);
            }
        }
        ExcelUtil<PreventionRiskStudyandjudge> util = new ExcelUtil<>(PreventionRiskStudyandjudge.class);
        util.exportExcel(response, promiseList, "风险研判(");
    }















}

